package com.ruoyi.web.controller.riskAssessment;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.riskAssessment.domain.RkWarning;
import com.ruoyi.riskAssessment.service.IRkWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 风险评估-预警Controller
 *
 * @author lth
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/riskAssessment/warning")
public class RkWarningController extends BaseController
{
    @Autowired
    private IRkWarningService rkWarningService;

    /**
     * 查询风险评估-预警列表
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:warning:list')")
    @GetMapping("/list")
    public TableDataInfo list(RkWarning rkWarning)
    {
        startPage();
        List<RkWarning> list = rkWarningService.selectRkWarningList(rkWarning);
        return getDataTable(list);
    }

    /**
     * 导出风险评估-预警列表
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:warning:export')")
    @Log(title = "风险评估-预警", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RkWarning rkWarning)
    {
        List<RkWarning> list = rkWarningService.selectRkWarningList(rkWarning);
        ExcelUtil<RkWarning> util = new ExcelUtil<RkWarning>(RkWarning.class);
        util.exportExcel(response, list, "风险评估-预警数据");
    }

    /**
     * 获取风险评估-预警详细信息
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:warning:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rkWarningService.selectRkWarningById(id));
    }

    /**
     * 新增风险评估-预警
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:warning:add')")
    @Log(title = "风险评估-预警", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RkWarning rkWarning)
    {
        return toAjax(rkWarningService.insertRkWarning(rkWarning));
    }

    /**
     * 修改风险评估-预警
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:warning:edit')")
    @Log(title = "风险评估-预警", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RkWarning rkWarning)
    {
        return toAjax(rkWarningService.updateRkWarning(rkWarning));
    }

    /**
     * 删除风险评估-预警
     */
    @PreAuthorize("@ss.hasPermi('riskAssessment:warning:remove')")
    @Log(title = "风险评估-预警", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rkWarningService.deleteRkWarningByIds(ids));
    }


    /**     风险预警列表
    * @Author lth
    * @Description //TODO
    * @Date 17:40 2024/1/4
    * @Param
    * @return
     **/

}
